package com.mx.recycle_demo.activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.mx.recycle_demo.R
import com.mx.recycle_demo.adapt.AutoHeightAdapt
import kotlinx.android.synthetic.main.activity_auto_height.*


class AutoHeightRecycleViewActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_auto_height)
        val adapter = AutoHeightAdapt(
            arrayListOf(
                R.mipmap.item1, R.mipmap.item2, R.mipmap.item3, R.mipmap.item4,
                R.mipmap.item5, R.mipmap.item6
            )
        )
//        zRecycleView.layoutManager = AutoHeightLayoutManager(this)
        zRecycleView.layoutManager =
            LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
        zRecycleView.adapter = adapter
        adapter.notifyDataSetChanged()
        adapter.setItemClick { index, record ->
            zRecycleView.smoothScrollToPosition(index)
        }
    }
}